<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <ul id="ulbox">
        <!-- <li>姓名：lilia,年龄：18</li> -->
    </ul>
    <script>
        let data=null;
        function getData() {//获取数据
            let xhr = new XMLHttpRequest;
            xhr.open("get", "./two.json", false)
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4 && xhr.status === 200) {
                    //console.log(JSON.parse(xhr.response));
                    data=JSON.parse(xhr.response);
                }
            }
            xhr.send(null);
        }
        getData()

        function render(){//循环渲染
            let str="";
            for(let i=0;i<data.length;i++){
            str+=`<li>姓名：${data[i].name},年龄：${data[i].age}</li>`
            }
            ulbox.innerHTML=str;
        }
        render()

        
        
    </script>
</body>

</html>